package com.zqh.app.manager.impl;

import com.zqh.app.dao.ArticleMapper;
import com.zqh.app.entity.SungoArticle;
import com.zqh.app.manager.ArticleManager;
import com.zqh.common.entity.Page;
import com.zqh.common.entity.Query;
import com.zqh.common.entity.R;
import com.zqh.common.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("articleManager")
public class ArticleManagerImpl implements ArticleManager {
    @Autowired
    ArticleMapper articleMapper;
    @Override
    public List<SungoArticle> getArticles(Page<SungoArticle> page, Query form) {

        return articleMapper.listForPage(page,form);
    }

    @Override
    public R delArticles(int articleId) {
        int count = articleMapper.remove(articleId);
        return CommonUtils.msg(count);
    }

    @Override
    public R addArticles(Query form) {
        int count = articleMapper.save(form);
        return CommonUtils.msg(count);
    }

    @Override
    public R updateArticles(Query form) {
        int count = articleMapper.update(form);
        return CommonUtils.msg(count);
    }
}
